import Cookies from 'js-cookie'
const TokenKey = 'user-token'
import cache from "@/plugins/cache";
import {userinfo} from "@/constants/userConstant";


export function getTokenold() {
  return Cookies.get(TokenKey)
}

export function getToken() {
  let userInfo = cache.local.get(userinfo)
  let jsonUserInfo = JSON.parse(userInfo)
  if (jsonUserInfo === null || jsonUserInfo === undefined){
    return null
  }
  let tokenValue = jsonUserInfo.token.tokenValue
  return tokenValue
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
